import Vue from 'vue'
import VueRouter from 'vue-router'

// import app from '../App.vue'
import login from '../components/login.vue'
import index from '../components/index.vue'
import info from '../components/info.vue'
import article from '../components/article.vue'
import update from '../components/update.vue'
import updatePwd from '../components/updatePwd.vue'
import choose from '../components/article/choose.vue'
import choosed from '../components/article/choosed.vue'
import task from '../components/article/task.vue'
import report from '../components/article/report.vue'
import record from '../components/article/record.vue'
import paper from '../components/article/paper.vue'
import card from '../components/article/card.vue'
import message from '../components/article/message.vue'
import getmessage from '../components/article/getmessage.vue'
import teacherinfo from '../components/article/teacherinfo.vue'
import mytopic from '../components/article/mytopic.vue'
import topic from '../components/article/topic.vue'
import record_text from '../components/article/record_text.vue'
// 教师模块
import index_teacher from '../components/index_teacher.vue'
import teacher_notice from '../components/teacher_notice.vue'
import student_paper from '../components/student_paper.vue'
import choose_true from '../components/student_paper/choose_true.vue'
import pass_report from '../components/student_paper/pass_report.vue'
import see_paper from '../components/student_paper/see_paper.vue'
import send_message from '../components/student_paper/send_message.vue'
import student_info from '../components/student_paper/student_info.vue'
import student_message from '../components/student_paper/student_message.vue'
import record_choose from '../components/student_paper/record_choose.vue'
import teacher_message from '../components/student_paper/teacher_message.vue'
import get_message from '../components/student_paper/get_message.vue'
import studentinfo from '../components/teacher/studentinfo.vue'
import write_paper from '../components/teacher/write_paper.vue'
import review_group from '../components/teacher/review_group.vue'
import graduation_group from '../components/teacher/graduation_group.vue'
import teacher_info from '../components/teacher/teacher_info.vue'
import write_record from '../components/student_paper/write_record.vue'
import paper_title from '../components/paper_title.vue'
import read_teacher from '../components/student_paper/read_teacher'

// 系管理员
import index_minAdmin from '../components/index_minAdmin.vue'
import collageinfo from '../components/minAdmin/collageinfo.vue'
import notice from '../components/minAdmin/notice.vue'
import pass_paper from '../components/minAdmin/pass_paper.vue'
import send_notice from '../components/minAdmin/send_notice.vue'
import check from '../components/minAdmin/check.vue'
import madmin_topic from '../components/minAdmin/madmin_topic.vue'
import update_info from '../components/minAdmin/update_info.vue'
import collage_teacher from '../components/minAdmin/collage_teacher.vue'
import collage_teacherinfo from '../components/minAdmin/collage_teacherinfo.vue'
import review from '../components/minAdmin/review.vue'
import look_teacher from '../components/minAdmin/look_teacher.vue'
import paper_score from '../components/minAdmin/paper_score.vue'
import distribution from '../components/minAdmin/distribution.vue'
import minadmin_info from '../components/minAdmin/minadmin_info.vue'

// 学校管理员
import index_bigAdmin from '../components/index_bigAdmin.vue'
import bigadmin_info from '../components/bigAdmin/bigadmin_info.vue'
import collage_info from '../components/bigAdmin/collage_info.vue'
import collage_paper from '../components/bigAdmin/collage_paper.vue'
import student_allInfo from '../components/bigAdmin/collage_info/student_allInfo.vue'
import teacher_allInfo from '../components/bigAdmin/collage_info/teacher_allInfo.vue'
import secondary_college from '../components/bigAdmin/collage_info/secondary_college.vue'
import checks from '../components/bigAdmin/passPaper/checks.vue'
import passPaper from '../components/bigAdmin/passPaper.vue'
import madmin_topics from '../components/bigAdmin/passPaper/madmin_topics.vue'
import reviews from '../components/bigAdmin/passPaper/reviews.vue'
import look_teachers from '../components/bigAdmin/passPaper/look_teachers.vue'
import distributions from '../components/bigAdmin/passPaper/distributions.vue'


Vue.use(VueRouter)

const routes = [
  // { path: '/', component: app },
  { path: '/', redirect: '/login' },
  { path: '/login', component: login },
  // 教师模块-------------------------------------------
  {
    path: '/index_teacher',
    component: index_teacher,
    redirect: '/teacher_notice',
    children: [
      { path: '/teacher_notice', component: teacher_notice },
      { path: '/paper_title', component: paper_title },
      { path: '/teacher_info', component: teacher_info },
      { path: '/write_paper', component: write_paper },
      { path: '/read_teacher', component: read_teacher },
      { path: '/review_group', component: review_group },
      { path: '/graduation_group', component: graduation_group },
      {
        path: '/student_paper',
        component: student_paper,
        redirect: '/choose_true',
        children: [
          { path: '/choose_true', component: choose_true },
          { path: '/get_message', component: get_message },
          { path: '/teacher_message', component: teacher_message },
          { path: '/studentinfo', component: studentinfo },
          { path: '/pass_report', component: pass_report },
          { path: '/write_record', component: write_record },
          { path: '/see_paper', component: see_paper },
          { path: '/send_message', component: send_message },
          { path: '/student_info', component: student_info },
          { path: '/student_message', component: student_message },
          { path: '/record_choose', component: record_choose },
        ]
      }
    ]
  },
  // 学院管理模块----------------------------------------------------
  {
    path: '/index_minAdmin',
    component: index_minAdmin,
    redirect: '/notice',
    children: [
      { path: '/notice', component: notice },
      { path: '/update_info', component: update_info },
      { path: '/minadmin_info', component: minadmin_info },
      { path: '/collage_teacherinfo', component: collage_teacherinfo },
      { path: '/collage_teacher', component: collage_teacher },
      {
        path: '/collageinfo', component: collageinfo
      },
      {
        path: '/pass_paper',
        component: pass_paper,
        redirect: '/check',
        children: [
          { path: '/check', component: check },
          { path: '/madmin_topic', component: madmin_topic },
          { path: '/distribution', component: distribution },
          { path: '/review', component: review },
          { path: '/look_teacher', component: look_teacher },
          { path: '/paper_score', component: paper_score }
        ]
      },
      { path: '/send_notice', component: send_notice },
    ]
  },

  // 学校管理员模块
  {
    path: '/index_bigAdmin',
    component: index_bigAdmin,
    redirect: '/collage_info',
    children: [
      {
        path: '/collage_info',
        component: collage_info,
        redirect: '/student_allInfo',
        children: [
          { path: '/student_allInfo', component: student_allInfo },
          { path: '/teacher_allInfo', component: teacher_allInfo },
          { path: '/secondary_college', component: secondary_college },
        ]
      },
      {
        path: '/collage_paper', component: collage_paper
      },
      {
        path: '/passPaper', component: passPaper,
        redirect: '/checks',
        children: [
          { path: '/checks', component: checks },
          { path: '/madmin_topics', component: madmin_topics },
          { path: '/distributions', component: distributions },
          { path: '/reviews', component: reviews },
          { path: '/look_teachers', component: look_teachers },
        ]
      },
      {
        path: '/bigadmin_info', component: bigadmin_info
      },
    ]
  },

  // 学生模块
  {
    path: '/index',
    component: index,
    // 重定向
    redirect: '/info',
    children: [
      { path: '/info', component: info },
      {
        path: '/article',
        component: article,
        // 重定向
        redirect: '/choose',
        children: [
          { path: '/topic', component: topic },
          { path: '/choose', component: choose },
          { path: '/choosed', component: choosed },
          { path: '/task', component: task },
          { path: '/report', component: report },
          { path: '/record', component: record },
          { path: '/record_text', component: record_text },
          { path: '/paper', component: paper },
          { path: '/card', component: card },
          { path: '/message', component: message },
          { path: '/getmessage', component: getmessage },
          { path: '/teacherinfo', component: teacherinfo },
          { path: '/mytopic', component: mytopic }
        ]
      },
      { path: '/update', component: update },
      { path: '/updatePwd', component: updatePwd }]
  }

]

const router = new VueRouter({
  routes
})

// 挂载路由导航守卫,判断你是否有token值来判断页面的跳转
router.beforeEach(function (to, from, next) {
  // to表示要访问的路径，from表示从那个路径过来
  if (to.path === '/login') return next()
  const token = window.sessionStorage.getItem('token')
  if (!token) return next('/login')
  next()
})

export default router
